gtk/imcontextwayland: Unset focus when unsetting widget
authorCarlos Garnacho <carlosg@gnome.org>
Thu, 5 Nov 2020 15:00:29 +0000 (16:00 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 5 Nov 2020 20:29:20 +0000 (21:29 +0100)
In destruction paths of a focused entry, the IM context might first
end up detached from its widget, then destroyed. This currently prevents
the IM context from detaching itself from the GtkIMContextWaylandGlobal.

Make it do so when unsetting the client widget, so the IM context gets
properly unfocused before destruction.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3176
gtk/gtkimcontextwayland.c

index 70b46e317f7606ef1231411fac760e0c3dfc0a17..ad89d83a07aaf04cff6618b76ece6c55bb582d02 100644 (file)
@@ -546,6 +546,7 @@ gtk_im_context_wayland_set_client_widget (GtkIMContext *context,
 
   if (context_wayland->widget)
     {
+      gtk_im_context_wayland_focus_out (context);
       gtk_widget_remove_controller (context_wayland->widget, GTK_EVENT_CONTROLLER (context_wayland->gesture));
       context_wayland->gesture = NULL;
     }